// 部门管理模块
import * as User from './Users'

/**
 * 获取用户列表并按 deptId 统计数量，并将结果赋值给 deptCountMap.value
 */
export async function getDeptUserCountMap(): Promise<void> {
  const ress = await User.getAll({ pageSize: 9999 })
  return ress.reduce((acc: Record<number, number>, user: any) => {
    const deptId = user.deptId
    if (acc[deptId]) {
      acc[deptId] += 1
    } else {
      acc[deptId] = 1
    }
    return acc
  }, {})
}